<template>
    <table>
        <tr>
            <td>手机号</td>
            <td><input type="text" v-model="info.phone"></td>
        </tr>
        <tr>
            <td>密码</td>
            <td><input type="password" v-model="info.pwd"></td>
        </tr>
        <tr>
            <td>确认密码</td>
            <td><input type="password" v-model="info.qpwd"></td>
        </tr>
        <tr>
            <td><input type="button" value="注册" @click="zhuce"></td>
        </tr>
    </table>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useRouter } from "vue-router";

const router=useRouter()
const info=ref({
    phone:"",
    pwd:"",
    qpwd:""
})

const zhuce=()=>{
    if(info.value.phone==""){
        alert('手机号不能为空')
        return
    }
    if(info.value.pwd==""){
        alert('密码不能为空')
        return
    }
    if(info.value.qpwd==""){
        alert('确认密码不能为空')
        return
    }
    
    if(info.value.phone!="13512349876"){
        alert('手机号不正确')
        return
    }
   if(info.value.pwd.length<6){
        alert('密码长度不能小于6位')
        return
    }
    
   if(info.value.pwd!='123456'){
    alert('密码格式不对')
    return
   }
   
    if(info.value.pwd!=info.value.qpwd){
        alert('两次密码不一致')
        return
    }

    router.push({
        name:"users",
        params:{
            phone:info.value.phone,
           
        }

    })
    
}
</script>